home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / mcomm557.zip / ZMDOS.H < prev    next >
C/C++ Source or Header  |  1993-09-11  |  19KB  |  386 lines

  1.  
  2. /*/////////////////////////////////////////////////////////////////////
  3. //                                                                   //
  4. //  ZMDOS.H -- zmodem protocol header file                           //
  5. //                                                                   //
  6. //    Mike Dumdei, 6 Holly Lane, Texarkana TX, 75503                 //
  7. //                                                                   //
  8. //////////////////////////////////////////////////////////////////// */
  9. #ifdef __cplusplus
  10.   extern "C" {
  11. #endif
  12.  
  13. /*/////////////////////////////////////////////////////////
  14. //                                                       //
  15. //  general                                              //
  16. //                                                       //
  17. //////////////////////////////////////////////////////// */
  18. typedef unsigned char BYTE;
  19. typedef unsigned int WORD;
  20. typedef unsigned long DWORD;
  21.  
  22. /*/////////////////////////////////////////////////////////
  23. //                                                       //
  24. //  compiler specific                                    //
  25. //                                                       //
  26. //////////////////////////////////////////////////////// */
  27. #ifndef __TURBOC__
  28.   #ifndef __ZTC__
  29.     #define __MSC__
  30.   #endif
  31. #endif
  32.  
  33. #define MAX_PATH            148
  34. #define KBHIT               _bios_keybrd(1)
  35. #define KBREAD              _bios_keybrd(0)
  36. #define Upd16Crc(crc,c)     ((Crc16Tbl[(crc) >> 8]) ^ (((crc) << 8) ^ (c)))
  37.  
  38. /*--------------------------------------------+
  39. |  DOS findfirst/findnext structure           |
  40. +--------------------------------------------*/
  41. typedef struct
  42. {
  43.     char reserved[21];
  44.     char attrib;
  45.     unsigned time;
  46.     unsigned date;
  47.     long size;
  48.     char name[13];
  49. } DF;
  50.  
  51. #ifdef __TURBOC__
  52.   #if (__TURBOC__ < 0x400)
  53.     #define _A_NORMAL           0
  54.     #define _A_RDONLY           FA_RDONLY
  55.     #define _A_SUBDIR           FA_DIREC
  56.     #define _A_HIDDEN           FA_HIDDEN
  57.     #define _A_SYSTEM           FA_SYSTEM
  58.     #define _A_VOLID            FA_LABEL
  59.   #endif
  60. #endif
  61.  
  62. #ifndef _MAX_PATH
  63.  #define _MAX_PATH 148
  64. #endif
  65.  
  66. /*/////////////////////////////////////////////////////////
  67. //                                                       //
  68. //  selected definitions from Chuck Forsberg's PD zmodem //
  69. //                                                       //
  70. //////////////////////////////////////////////////////// */
  71. /*--------------------------------------------+
  72. |  limits                                     |
  73. +--------------------------------------------*/
  74. #define ZATTNLEN    32        /* max length of attention string */
  75. #define MAXPACKET 1024        /* maximum size of a packet */
  76.  
  77. /*--------------------------------------------+
  78. |  special character definitions              |
  79. +--------------------------------------------*/
  80. #define ZPAD        '*'       /* pad char - begins zmodem frames */
  81. #define ZDLE      '\x18'      /* zmodem escape - aka CAN, Ctrl-X */
  82. #define ZBIN        'A'       /* binary frame indicator (CRC-16) */
  83. #define ZHEX        'B'       /* hex frame indicator */
  84. #define ZBIN32      'C'       /* binary frame indicator (CRC-32) */
  85. #define XON       '\x11'      /* XON character */
  86.  /*++ zdle sequences ++*/
  87. #define ZCRCE       'h'       /* CRC next, frame ends, hdr packet follows */
  88. #define ZCRCG       'i'       /* CRC next, frame continues nonstop */
  89. #define ZCRCQ       'j'       /* CRC next, frame continues, ZACK expected */
  90. #define ZCRCW       'k'       /* CRC next, ZACK expected, end of frame */
  91. #define ZRUB0       'l'       /* translate to DEL '\x7f' */
  92. #define ZRUB1       'm'       /* translate to DEL '\xff' */
  93. #define GOTCRCE (ZCRCE|256)   /* ZDLE-ZCRCE received */
  94. #define GOTCRCG (ZCRCG|256)   /* ZDLE-ZCRCG received */
  95. #define GOTCRCQ (ZCRCQ|256)   /* ZDLE-ZCRCQ received */
  96. #define GOTCRCW (ZCRCW|256)   /* ZDLE-ZCRCW received */
  97. #define GOTCAN     (256)      /* got 5 ZDLEs */
  98.  
  99. /*--------------------------------------------+
  100. |  zmodem frame types                         |
  101. +--------------------------------------------*/
  102. #define ZRQINIT      0        /* request receiver init */
  103. #define ZRINIT       1        /* receiver init */
  104. #define ZSINIT       2        /* sender init sequence (optional) */
  105. #define ZACK         3        /* zmodem ACK */
  106. #define ZFILE        4        /* file name from sender */
  107. #define ZSKIP        5        /* to sender: skip this file */
  108. #define ZNAK         6        /* zmodem NAK */
  109. #define ZABORT       7        /* abort batch transfers */
  110. #define ZFIN         8        /* finish session */
  111. #define ZRPOS        9        /* resume data trans at this position */
  112. #define ZDATA       10        /* data packet(s) follow */
  113. #define ZEOF        11        /* end of file */
  114. #define ZFERR       12        /* disk I/O error detected */
  115. #define ZCRC        13        /* request for file CRC and response */
  116. #define ZCHALLENGE  14        /* receiver's challenge */
  117. #define ZCOMPL      15        /* request is complete */
  118. #define ZCAN        16        /* other end canned session with CAN*5 */
  119. #define ZFREECNT    17        /* request for free bytes on filesystem */
  120. #define ZCOMMAND    18        /* command from sending program */
  121. #define ZSTDERR     19        /* output to standard error, data follows */
  122.  
  123. /*--------------------------------------------+
  124. |  Bit Masks for ZRINIT ZF0 flags             |
  125. +--------------------------------------------*/
  126. #define CANFDX     0x01       /* receiver can send and receive true FDX */
  127. #define CANOVIO    0x02       /* receiver can receive during disk I/O */
  128. #define CANBRK     0x04       /* receiver can send a break signal */
  129. #define CANCRY     0x08       /* receiver can decrypt */
  130. #define CANLZW     0x10       /* receiver can uncompress */
  131. #define CANFC32    0x20       /* receiver can use 32 bit Frame Check */
  132. #define ESCCTL     0x40       /* receiver expects ctl chars to be escaped */
  133. #define ESC8       0x80       /* receiver expects 8th bit to be escaped */
  134.  
  135. /*--------------------------------------------+
  136. |  Bit Masks for ZSINIT ZF0 flags             |
  137. +--------------------------------------------*/
  138. #define TESCCTL    0x40       /* tx expects ctl chars to be escaped */
  139. #define TESC8      0x80       /* tx expects 8th bit to be escaped */
  140.  
  141. /*--------------------------------------------+
  142. |  Bit masks for ZFILE header flags           |
  143. +--------------------------------------------*/
  144.  /*++ ZF0 flag, conversion options ++*/
  145. #define ZCBIN        1      /* binary transfer - inhibit conversion */
  146. #define ZCNL         2      /* convert NL to local end of line convention */
  147. #define ZCRESUM      3      /* resume interrupted file transfer */
  148.  /*++ ZF1 flag, management options ++*/
  149. #define ZMSKNOLOC  0x80     /* skip file if not present at rx */
  150. #define ZMMASK     0x1f     /* mask for the choices below */
  151. #define ZMNEWL       1      /* transfer if source newer or longer */
  152. #define ZMCRC        2      /* transfer if different file CRC or length */
  153. #define ZMAPND       3      /* append contents to existing file (if any) */
  154. #define ZMCLOB       4      /* replace existing file */
  155. #define ZMNEW        5      /* transfer if source newer */
  156. #define ZMDIFF       6      /* transfer if dates or lengths different */
  157. #define ZMPROT       7      /* protect destination file */
  158.  
  159. /*--------------------------------------------+
  160. |  Error return values                        |
  161. +--------------------------------------------*/
  162. #define GARB_COUNT     (-12)    /* header not found on call to ZRecvHdr */
  163. #define LONG_PKT       (-11)    /* exceeded expected block length */
  164. #define GARBLED_PKT    (-10)    /* unexpected data/invalid ZDLE sequence */
  165. #define BAD_CRC         (-9)    /* CRC incorrect */
  166. #define TIMED_OUT       (-8)    /* timed out on character receive */
  167.  
  168. #define SYNC_ERR        (-6)    /* couldn't synchronize file positions */
  169. #define MEM_ERR         (-5)    /* memory allocation error */
  170. #define FILE_ERR        (-4)    /* DOS read/write error */
  171. #define LOST_CARRIER